<?php

use yii\db\Migration;

class m210222_083036_addon_employees extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%addon_employees}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID'",
            'merchant_id' => "int(11) NOT NULL",
            'serial' => "varchar(32) NOT NULL COMMENT '员工编号'",
            'name' => "varchar(32) NOT NULL COMMENT '姓名'",
            'pinyin' => "varchar(32) NULL COMMENT '拼音'",
            'age' => "int(11) NULL COMMENT '年龄'",
            'gender' => "int(1) NOT NULL COMMENT '性别'",
            'birthday' => "date NULL COMMENT '生日'",
            'idcard' => "varchar(18) NOT NULL COMMENT '身份证'",
            'native' => "varchar(32) NULL COMMENT '籍贯'",
            'political' => "int(11) NULL COMMENT '政治面貌'",
            'education' => "varchar(32) NULL COMMENT '学历'",
            'colleges' => "varchar(32) NULL COMMENT '毕业院校'",
            'residence' => "varchar(32) NULL COMMENT '户口所在地'",
            'mobile' => "varchar(32) NULL COMMENT '手机'",
            'mail' => "varchar(32) NULL COMMENT '邮箱'",
            'picture' => "varchar(255) NULL COMMENT '主图'",
            'covers' => "text NULL",
            'status' => "int(11) NOT NULL DEFAULT '1' COMMENT '状态'",
            'created_at' => "int(11) NOT NULL COMMENT '创建时间'",
            'updated_at' => "int(11) NOT NULL COMMENT '修改时间'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%addon_employees}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

